import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_app_study/bean/up_data_entity.dart';
import 'package:flutter_app_study/generated/json/up_data_entity_helper.dart';
import 'package:flutter_app_study/utils/DioUtil.dart';

import '../../cost/ErpUrl.dart';

class SerialNumberFragment extends StatefulWidget {
  @override
  _SerialNumberFragmentState createState() => _SerialNumberFragmentState();
}

class _SerialNumberFragmentState extends State<SerialNumberFragment> {
  List<dynamic> list = [];
  var upDataEntity = UpDataEntity();
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    list.add("a");
    for (var i = 0; i < 10; ++i) {
      list.add(i);
    }
    list.add("b");
    for (var i = 10; i < 20; ++i) {
      list.add(i);
    }
    list.add("c");
    for (var i = 20; i < 35; ++i) {
      list.add(i);
    }
    list.add("d");
    for (var i = 35; i < 40; ++i) {
      list.add(i);
    }
    list.add("e");
    for (var i = 40; i < 50; ++i) {
      list.add(i);
    }
    var upDataEntity = UpDataEntity();
    DioUtil.post(ErpUrl.checkUpdateUrl,success: (data){
      upDataEntityFromJson(upDataEntity,json.decode(data));
      print(upDataEntity.toString());
    });



  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: ListView.builder(itemBuilder: (BuildContext context, int index) {
        print("1111${list[index] is int}");
        if (list[index] is int) {
          return Container(
            color: Colors.orangeAccent,
            child: Text(list[index].toString()),
          );
        } else if (list[index] is String) {
          return Container(
            color: Colors.blue,
            child: Row(
              children: <Widget>[
                Icon(Icons.ac_unit),
                Text(list[index]),
              ],
            ),
          );
        } else {
          return Container(
            color: Colors.red,
            child: Text("?????"),
          );
        }
      },itemCount: list.length,),
    );
  }
}
